Convert paragraph content to markdown#506
Closed
gurkerl83 wants to merge 2 commits intocode-hike:nextfrom
Closed
Conversation
- Introduce `isMarkdownEnabled` helper function to detect whether an MDX element sets `markdownEnabled` (either via shorthand or boolean expression). - Convert paragraph content to Markdown if `markdownEnabled` is set, accumulating the result in a new `node.markdown` field. - Use `toMarkdown` from `mdast-util-to-markdown` to transform AST nodes to Markdown.
|
@gurkerl83 is attempting to deploy a commit to the codehike Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Try |
gurkerl83
added a commit
to gurkerl83/codehike
that referenced
this pull request
Feb 18, 2026
Context: - This PR is based on `next`. - Prior work exists in code-hike#506 (not merged into `next`), and is referenced here as the previous approach. Top-level detail: - Previous approach (PR code-hike#506) generated `__hike.markdown` from AST serialization, so upstream remark AST mutations were reflected but source fidelity was not guaranteed. - This caused round-trip drift (formatting/line endings/GFM layout normalization). - This change generates `__hike.markdown` from original source offsets, prioritizing source-faithful output and side effect free plugin results. Additional changes: - Thread original source through the remark transform path into section serialization. - Compute markdown only from section content paragraphs using node offsets. - Preserve flow-level `<br />` spacing semantics: - leading breaks before the first paragraph, - one baseline separator newline plus extra newlines for intermediate `<br />`, - trailing breaks after the last paragraph. - Keep markdown export opt-in via `markdownEnabled` (attribute behavior unchanged). - Remove the extra markdown serialization dependency introduced in the previous approach. - Add focused tests for: - source-preserving markdown capture, - behavior when `markdownEnabled` is not set, - `<br />` spacing behavior.
Author
|
Closing in favor of #528 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isMarkdownEnabledhelper function to detect whether an MDX element setsmarkdownEnabled(either via shorthand or boolean expression).markdownEnabledis set, accumulating the result in a newnode.markdownfield.toMarkdownfrommdast-util-to-markdownto transform AST nodes to Markdown.